"use client";

import { useState } from "react";
import { Image } from "@heroui/image";

import LoginForm from "./components/LoginForm";

export default function LoginPage() {
  const [showLogin, setShowLogin] = useState(true);

  return (
    <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-[#e0f7fa] via-[#f1f8e9] to-[#ffe0b2]">
      <div className="w-full max-w-5xl flex bg-white bg-opacity-80 rounded-xl shadow-xl overflow-hidden">
        {/* 左图 */}
        <div className="w-1/2 p-8 hidden md:flex items-center justify-center">
          <Image alt="logo" src="/loginIllustration.png" />
        </div>

        {/* 右表单 */}
        <div className="w-full md:w-1/2 p-10 flex flex-col justify-center">
          <h2 className="text-2xl font-bold text-gray-800 mb-6">
            欢迎使用文档系统
          </h2>

          <LoginForm showLogin={showLogin} onChangeLogin={setShowLogin} />

          {/* 切换注册 */}
          <div className="mt-6 text-sm text-center text-gray-600">
            还没账号？
            <button
              className="text-blue-500 hover:underline ml-1"
              onClick={() => setShowLogin(!showLogin)}
            >
              {showLogin ? "点我注册" : "点我登录"}
            </button>
          </div>
        </div>
      </div>
    </div>
  );
}
